package com.pumpkin.web.busi.controller;

import com.pumpkin.web.model.Gender;
import com.pumpkin.web.model.UserModel;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 表达式语法相关测试
 *
 * @author jinlong.liao on 2016/7/7
 */
@Controller
@RequestMapping("/expressionSyntax")
public class expressionSyntaxController {


    @ModelAttribute("name")
    public String initName(@RequestParam(required = false) String name) {
        return name == null ? "姚明" : name;
    }

    @ModelAttribute("user")
    public UserModel initUser() {
        UserModel userModel = new UserModel();
        userModel.setId(1);
        userModel.setName("姚明");
        userModel.setAge(30);
        userModel.setGender(Gender.MALE);
        userModel.setUsername("sa");
        userModel.setPassword("sa");
        userModel.setAdmin(true);
        userModel.setRole("admin");
        return userModel;
    }

    @RequestMapping(value = "/messages", method = RequestMethod.GET)
    public String messages() {
        return "expressionSyntax/messages";
    }

    @RequestMapping(value = "/variables", method = RequestMethod.GET)
    public String variables() {
        return "expressionSyntax/variables";
    }
}
